<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html" charset="gb2312">
<title>CoolMeeting会议管理系统</title>
<link rel="stylesheet" href="styles/common.css" />
<script type="text/javascript" src="js/jquery-3.2.1.min.js"></script>
<script type="text/javascript">
var id;
var dname;
//修改按钮单击事件
$(function() {
	$('.update').click(function() {
		//name生成input
		name = $(this).parents('tr').children(':eq(1)').text();
		var nameInput = '<input type="text" value="' + name + '" />';
		$(this).parents('tr').children(':eq(1)').empty();
		$(this).parents('tr').children(':eq(1)').append(nameInput);
		//生成input
		id = $(this).parents('tr').children(':eq(0)').text();
		//确定显示
		$(this).next().show();
		//取消按钮显示
		$(this).next().next().show();
		//修改按钮隐藏
		$(this).hide();

	});
});
//确定按钮单击事件
$(function() {
	$('.confrim').click(function() {
		//向后台发送请求，进行跳转
		location.href="updateDept?departmentid="+$(this).parents('tr').children(':eq(0)').text()
				+"&departmentname="+$(this).parents('tr').children(':eq(1)').children(':eq(0)').val();

	});
});
//取消按钮事件
$(function(){
	$('.concel').click(function(){
		$(this).parents('tr').children(':eq(1)').empty();
		$(this).parents('tr').children(':eq(1)').text(name);
		//修改按钮显示
		$(this).prev().prev().show();
		//确定按钮隐藏
		$(this).prev().hide();
		//取消按钮隐藏
		$(this).hide();
	});
});
</script>

</head>
<body>
	<div class="page-header">
		<div class="header-banner">
			<img src="images/header.png" alt="CoolMeeting" />
		</div>
		<div class="header-title">欢迎访问Cool-Meeting会议管理系统</div>
		<div class="header-quicklink">
			欢迎您，<strong>${emp.employeename }</strong> <a href="changepassword.html">[修改密码]</a>
		</div>
	</div>
	<div class="page-body">
		<div class="page-sidebar">
			<div class="sidebar-menugroup">
				<div class="sidebar-grouptitle">个人中心</div>
				<ul class="sidebar-menu">
					<li class="sidebar-menuitem"><a href="notifications.jsp">最新通知</a></li>
					<li class="sidebar-menuitem active"><a href="myOrderMeeting">我的预定</a></li>
					<li class="sidebar-menuitem"><a href="mymeetings.html">我的会议</a></li>
				</ul>
			</div>
			<div class="sidebar-menugroup">
				<div class="sidebar-grouptitle">人员管理</div>
				<ul class="sidebar-menu">
					<li class="sidebar-menuitem"><a href="selectAllDepts">部门管理</a></li>
					<li class="sidebar-menuitem"><a href="register.jsp">员工注册</a></li>
					<li class="sidebar-menuitem"><a href="selectApproveAccount">注册审批</a></li>
					<li class="sidebar-menuitem"><a href="searchEmployees?employeestatus=1">搜索员工</a></li>
				</ul>
			</div>
			<div class="sidebar-menugroup">
				<div class="sidebar-grouptitle">会议预定</div>
				<ul class="sidebar-menu">
					<li class="sidebar-menuitem"><a href="addmeetingroom.jsp">添加会议室</a></li>
					<li class="sidebar-menuitem"><a href="selectMeetingRoom">查看会议室</a></li>
					<li class="sidebar-menuitem"><a href="bookmeeting.jsp">预定会议</a></li>
					<li class="sidebar-menuitem"><a href="selectMeetingPage">搜索会议</a></li>
				</ul>
			</div>
		</div>
		<div class="page-content">
			<div class="content-nav">人员管理 > 部门管理</div>
			<form action="insertDept">
				<fieldset>
					<legend>添加部门</legend>
					部门名称: <input type="text" name="departmentname" maxlength="20" /> <input
						type="submit" class="clickbutton" value="添加" />
				</fieldset>
			</form>
			<table class="listtable">
				<caption>所有部门:</caption>
				<tr class="listheader">
					<th>部门编号</th>
					<th>部门名称</th>
					<th>操作</th>
				</tr>
				<c:if test="${! empty depts }">
				   <c:forEach items="${depts }" var="dept">
				       <tr>
							<td>${dept.departmentid }</td>
							<td>${dept.departmentname }</td>
							<td>
							<a class="clickbutton update" href="#">编辑</a> 
							<a class="clickbutton confrim" style="display:none" href="#">确定</a>
							<a class="clickbutton concel" style="display:none" href="#" >取消</a>
							<a
								class="clickbutton" href="deleteDept?departmentid=${dept.departmentid }">删除</a></td>
						</tr>
				   </c:forEach>
				</c:if>
			</table>
		</div>
	</div>
	<div class="page-footer">
		<hr />
		更多问题，欢迎联系<a href="mailto:webmaster@eeg.com">管理员</a> <img
			src="images/footer.png" alt="CoolMeeting" />
	</div>
</body>
</html>